<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 								
	<head> 							
		<%@ include file="../jslib/jquerylib.jsp" %>
	    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
        <link href="<%=request.getContextPath() %>/web/style/layout.css" type="text/css" rel="stylesheet"/>
        <link rel="stylesheet" href="<%=request.getContextPath() %>/jslib/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
        <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/ztree/jquery.ztree.core-3.4.js"></script>
        <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
	       <!-- 删除结果信息返回 -->
	    	<c:if test="${requestScope.message!=null}">
				<script type="text/javascript">
	  	 		     alert('<c:out value="${requestScope.message}"></c:out>');
	  	 		     window.close();
	  			</script>
	        </c:if>
	 
	<script type="text/javascript">
	var jiluid = "${requestScope.id }";
	$(document).ready(function(){
				//高级搜索需要的js
				buttonStatus=1;
				$("#flip").click(function(){
					if(buttonStatus==1){
						$("#panel").slideToggle("slow");
						$("#flip").toggleClass("btnStatus2");
						buttonStatus=1;
					}
					else{
						$("#panel").slideUp("slow");
						$("#flip").toggleClass("btnStatus2");
					}
			 });
				 //高级搜索结束
					$("#gridTable").jqGrid({
						 url:'<%=request.getContextPath()%>/shebeiweibaojiluAction!queryShebeiweibaojiluList.action',
						datatype: "json",
						height: 250,
						width: 710, 
						autowidth: true, 
						colNames:['ID','记录名称'],
                    colModel:[
                        {name:'ID',index:'ID', width:60, key:true,hidedlg:true}, 
                        		{name:'SHEBEINAME',index:'SHEBEINAME', width:200},
								{name:'JILUNAME',index:'JILUNAME', width:500/* ,sortable:false,align:"center",formatter:function(cellvalue, options, rowObject){
return "<a onclick=\"selectequ()\" style='text-decoration:underline;color:blue'>"+cellvalue+"</a>"; }*/
								}
                    ],      
					shrinkToFit:false,
					sortname:'id',
					sortorder:'desc',
					viewrecords:true,
					multiselect: true, // 是否显示复选框
					multiboxonly : true, 
					//gridview: true,  //提升速度
					rownumbers: true,//显示行号
					rownumWidth: 30, //行号的宽度
					rowNum:15,
					rowNum:<%=session.getAttribute("SYS_PAGECOUNT")%>,
					ondblClickRow: function(rowid,iRow,iCol,e){
			            var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
						if (!ids) {   
						    alert("请先选择记录!");  
						    return false;  
						} 
						if(ids.indexOf(",")!=-1){
							  alert("只能选择一条记录!");  
						      return false; 
						}	
				 var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.

				       	refreshWeib(row.ID);
			        },
					rowList:[15,20,50,200,500],
					toolbar: [false,"top"],
					jsonReader: {
						root:"rows",		// 数据行（默认为：rows）
						page: "page",  	// 当前页
						total: "total",  // 总页数
						records: "records",  // 总记录数
						repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
					},
					prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
					pager:"#gridPager",
					caption: "维保记录台帐"
			});
			    $("#consoleDlg").dialog({
			        autoOpen: false,      
			        modal: true,    // 设置对话框为模态（modal）对话框  
			        resizable: true,      
			        width: 700,  
			        buttons: {  // 为对话框添加按钮  
			            "关闭": function() {$("#consoleDlg").dialog("close")}
			        }  
			    }); 
				 jQuery("#gridTable").jqGrid('navGrid','#gridPager',{add:false,edit:false,del:false,search:false,refresh:false});
					jQuery("#gridTable").jqGrid('navButtonAdd','#gridPager',
								{ 	
								caption: "",                          
								onClickButton : function (){                               
								jQuery("#gridTable").jqGrid('setColumns');                           
								}
					}); 
				
				
				$("#fromTable").jqGrid({
						url:'',
						datatype: "json",
						height: 250,
						width: 710,  
						autowidth: true, 
						colNames:['ID','设备名称','维保项目','设备编号','规格型号','实施人员','部门名称','维保工时','计划维保时间','实际维保时间','维保成本','备件更换情况描述','备件出库单号','异常处置情况','维护保养建议','附件'],
                   		colModel:[
                        		{name:'ID',index:'ID', width:50, key:true,hidden:true,hidedlg:true}, 
                        		{name:'SHEBEINAME',index:'SHEBEINAME', width:50},
                        		{name:'WEIBAOXIANGMU',index:'WEIBAOXIANGMU', width:50},	
								{name:'SHEBEINO',index:'SHEBEINO', width:50},
								{name:'GUIGEXINGHAO',index:'GUIGEXINGHAO', width:50},
								{name:'SHISHIRENYUAN',index:'SHISHIRENYUAN', width:50},								
								{name:'BUMENNAME',index:'BUMENNAME', width:50},
								{name:'WEIBAOGONGSHI',index:'WEIBAOGONGSHI', width:50},
								{name:'JIHUAWEIBAOTIME',index:'JIHUAWEIBAOTIME', width:60},
								{name:'SHIJIWEIBAOTIME',index:'SHIJIWEIBAOTIME', width:60},
								{name:'WEIBAOCHENGBEN',index:'WEIBAOCHENGBEN', width:50},
								{name:'GENGHUANMIAOSHU',index:'GENGHUANMIAOSHU', width:50},
								{name:'CHUKUDANHAO',index:'CHUKUDANHAO',width:50},
								{name:'YICHANGCHUZHI',index:'YICHANGCHUZHI',width:50},
								{name:'WEIBAOJIANYI',index:'WEIBAOJIANYI', width:50},
								{name:'FUJIAN',index:'FUJIAN', width:50},
                    ],
					shrinkToFit:false,
					sortname:'id',
					sortorder:'desc',
					viewrecords:true,
					multiselect: true, // 是否显示复选框
					multiboxonly : true, 
					//gridview: true,  //提升速度
					rownumbers: true,//显示行号
					rownumWidth: 30, //行号的宽度
					rowNum:15,
					rowList:[15,20,50,200,500],
					toolbar: [false,"top"],
					loadComplete: function() {
					},
					jsonReader: {
						root:"rows",		// 数据行（默认为：rows）
						page: "page",  	// 当前页
						total: "total",  // 总页数
						records: "records",  // 总记录数
						repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
					},
					prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
					pager:"#fromPager",
					caption: "设备维保列表"
			});	
			
			doResize(); 
	}); 
	
	//执行大小
	
	function doResize() { 
		var ss = getPageSize(); 
		//alert(ss.WinH);
		
			 $("#gridTable").jqGrid('setGridHeight', ss.WinH-445);
			 $("#gridTable").jqGrid('setGridWidth', ss.WinW-30); 
			 $("#fromTable").jqGrid('setGridHeight', ss.WinH-245);
			 $("#fromTable").jqGrid('setGridWidth', ss.WinW-30); 
			} 
		
	
		
       //修改
		function updateE(){
			var ids= $("#fromTable").jqGrid("getGridParam", "selarrrow") + "";
			if (!ids) {
			    alert("请先选择记录!");  
			    return false;  
			}
			if(ids.indexOf(",")!=-1){
				  alert("只能选择一条记录!");  
			        return false; 
			}
			
			var row = jQuery("#fromTable").jqGrid("getRowData",ids);//获取选中行.
			var id = row.ID;//获取选中行的id属性.
			$.dialog({
		        title: '设备维保信息修改',
		        content: 'url:'+ '<%=request.getContextPath() %>/shebeiweibaojiluAction!queryweibaoById.action?id='+id+'&temp='+Math.round(Math.random()*10000),
		        okVal: false,//确定按钮文字
		        cancelVal: false,//取消按钮文字
		        min: true, //是否显示最小化按钮
		        max: false,//是否显示最大化按钮
		        fixed: false,//开启静止定位
		        lock: true,//开启锁屏
		        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
		        time: null,//设置对话框显示时间
		        resize: true,//是否允许用户调节尺寸
		        drag: true,//是否允许用户拖动位置
		        cache: false,//是否缓存iframe方式加载的窗口内容页
		        width: '800px',
		        height:  550
			});
		}
		//刷新
		function refreshIt(){
			//resetSearch();
			jQuery("#gridTable").jqGrid('setGridParam',
			{
				 url:'<%=request.getContextPath()%>/shebeiweibaojiluAction!queryShebeiweibaojiluList.action',
			}).trigger("reloadGrid", [{page:1}]);
		    
		}
		function reload(){
			refreshIt();
			refreshWeib();
		}
		
	 
		
	function addDataWb(){
			var datas = window.showModalDialog("<%=request.getContextPath() %>/view/shebeiweibaojilu_select.jsp?jiluid="+jiluid+"&temp="+Math.round(Math.random()*10000),'',"dialogWidth=960px;dialogHeight=600px");
		 	refreshIt();
		 	refreshWeib();
		 }
	//查询
		function refreshWeib(id){
            var params = {  
                        }
            var postData = $("#fromTable").jqGrid("getGridParam", "postData");
            $.extend(postData, params);
			jQuery("#fromTable").jqGrid('setGridParam',
			{
				url:'<%=request.getContextPath() %>/shebeiweibaojiluAction!querywbList.action?flag=0&id='+id
			}).trigger("reloadGrid", [{page:1}]);
        } 
	</script>	
	</head>
	<body>
	<form action="" method="post" id="form1">
		<input type="hidden" id="jiluid" name="jiluid" value="${requestScope.id }" />
		<div style="height: 300px;">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
		   		<td>
			 		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="font12Black_B">
			   		<tr>
			            <td width="15%" align="right">&nbsp;<input type="button" name="button" id="button" value="添加" onclick="addDataWb()" class="search_Btn" />
			      			&nbsp;<input type="button" name="button3" id="button3" value="删除" onclick="reset()" class="search_Btn" />
			      		</td>
			        </tr>
			      </table>
		  		</td>
		 	  </tr>
			</table>
			<table style="width: 100%;height: 220px" class="tableCont">
				<tr>
					<td colspan="4" style="padding-top:8px;">
						<table id="gridTable"></table>
						<div id="gridPager"></div>
					</td>
				</tr>
		   </table>
		   </div>
		   <div id="weibaodata" style="height: 500px; ">
		   		<table style="width: 100%;height: 220px" class="tableCont">
		   		<tr>
		   			<td><input type="button" id="updateBtn" value="修改" onclick='updateE()' class='button_b' /></td>
		   		</tr>
				<tr>
					<td colspan="4" style="padding-top:8px;">
						<table id="fromTable"></table>
						<div id="fromPager"></div>
					</td>
				</tr>
		   </table>
		   </div>
	</form>
	</body>
</html>
